package com.rykj.energy.common.enums;

public enum WeeksEnum {
    //Mon,Tue,Wed,Thu,Fri,Sat,Sun
    Mon("星期一",2),
    Tue("星期二",3),
    Wed("星期三",4),
    Thu("星期四",5),
    Fri("星期五",6),
    Sat("星期六",7),
    Sun("星期日",1);


    private String name;
    private Integer code;

    WeeksEnum(String name, Integer code){
        this.name = name;
        this.code = code;
    }
    public static Integer getCodeByName(String name){
        if(null==parseByName(name)){
          return null;
        }
        return parseByName(name).getCode();
    }

    public static String getNameByCode(String code){
        if(null==parseByCode(code)){
            return "";
        }
        return parseByCode(code).getName();
    }

    public static WeeksEnum parseByName(String name){
        for(WeeksEnum type : values()){
            if(type.getName().equals(name)){
                return type;
            }
        }
        return null;
    }

    public static WeeksEnum parseByCode(String code){
        for(WeeksEnum type : values()){
            if(type.getCode().equals(code)){
                return type;
            }
        }
        return null;
    }

    public String getName() {
        return name;
    }

    public Integer getCode() {
        return code;
    }

    }
